// src/main/java/com/bookmanager/service/UserService.java
package com.bookmanager.service;

import com.bookmanager.dao.UserDAO;
import com.bookmanager.model.User;

public class UserService {
    private UserDAO userDAO = new UserDAO();

    public User login(String userId, String password) {
        return userDAO.login(userId, password);
    }

    public User getUserById(String userId) {
        return userDAO.getUserById(userId);
    }

    public boolean register(User user) {
        // 检查用户是否已存在
        if (userDAO.getUserById(user.getUserId()) != null) {
            return false;
        }
        return userDAO.addUser(user);
    }
}